#ifndef PLAYER_H_INCLUDED
#define PLAYER_H_INCLUDED

#define Gravite 250                                 // pixel to second square
#define Acceleration 10                             // pixel to second sqaure (temp)
#define MaxLife 99									// Max Life
#define Maxbanana 99								// Max banana
#define MaxMaintainOfSpace 0.4						// Max Time of Maintain the key space
#define MaxSpeedJump -350                           // Max speed jump
#define Accelerationjump 3.2                        // Use for to jump more high
#define Accelerationwalk 100                        // Use for to walk
#define DecelerateWalk 1000

#include "../define.hpp"
#include "../App.hpp"
#include "physic.hpp"
#include "level/Character.hpp"

enum SelectPlayer
{
    DONKEY,
    DIDDY
};

enum AliveCharacter
{
	NONE,
	DONKEY_KONG,
    DIDDY_KONG,
	BOTH
};

enum Kong
{
	K,O,N,G
};

enum MouvementOfPlayer
{
    IDLE,
    WALK,
    RUN,
    ATTACK,
    ROULADE,
    TAKEOFF,
    INAIR,
    LANDING,
    CHANGECHARACTER,
    DIE
};

enum PlayerDirection
{
    Right,
    Left,
    None
};

class Player
{
    public:

    //Constructor
    Player(App* appPtr,Physic* physic);
    //Set Position
    void SetPosition(sf::Vector2f position);
    //Get Position
    sf::Vector2f GetPosition();
    //Add Life
    void AddLife(unsigned int life = 1);
    //Remove Life
    void RemoveLife(unsigned int life = 1);
    //Get Life
    int GetLife();
    //Add Banane
    void AddBanane(unsigned int banana = 1);
    //Get Banane
    int GetBanana();
    //Add Kong (1 = K,2 = O,3 = N,4 = G)
	void AddKong(Kong letter);
	//if The word Kong is complet return true
	bool GetKong();
	//Draw Character
	sf::Sprite DrawCharacter();
	//Update of Player
    void Update(float ElapsedTime);
	//Event of Donkey kongs
	void Input(const sf::Input& input);

	//variable public
	int m_life;
    int m_banana;

    private:

    //function private
    void CharacterInAir();

    void Gravity();

    void Decalage();

    void Animation();

    //Class
    //Animation *m_animation;
    Character* m_character;

    AliveCharacter m_aliveCharacter;
    SelectPlayer m_selectPlayer;
    MouvementOfPlayer m_MouvementOfPlayer;

    float m_Space;    // mesure the space between the character and the block
    float m_SpeedJump;
    float m_LastJumpClock;
    float m_LastWalkClock;
    float m_LastDecelerationWalkClock;
    bool m_KONG[4];
    bool m_Deceleration;
    PlayerDirection m_Direction;
    sf::Vector2f m_position;
    sf::Vector2f m_Decalage;

    //Clock
    sf::Clock m_JumpClock;   // mesure the time in air
    sf::Clock m_WalkClock;   // mesure the time to walk
    sf::Clock m_DecelerationClock; // mesure Deceleration time
    sf::Clock m_WaitingTime;

    // Pointer to main App and Physic
	App* m_app;
	Physic* m_physic;

	// Temporaire
	sf::Image m_donkey_I;
	sf::Sprite m_donkey_S;
};

#endif // PLAYER_H_INCLUDED
